import React from "react";
import { useSearchParams, useLocation } from "react-router-dom";

export default function Detail() {
    // 接收search参数
    const [search, setSearch] = useSearchParams();

    const title = search.get("title");
    const content = search.get("content");

    // 使用useLocation() hook接收search参数
    const x = useLocation();
    console.log(x);

    return (
        <div>
            <h4>{title}</h4>
            <div>{content}</div>
            <div>
                <button
                    onClick={() => setSearch("id=008&title=哈哈&content=嘻嘻")}
                >
                    点我更新一下search参数
                </button>
            </div>
        </div>
    );
}
